package View.LinearFilterTable;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: Andrew
 * Date: 10.03.12
 * Time: 18:33
 * To change this template use File | Settings | File Templates.
 */
public class LinearFilterTableRenderer extends DefaultTableCellRenderer
{
    private LinearFilterTableModel tableModel;

    public LinearFilterTableRenderer(LinearFilterTableModel tableModel) {
        this.tableModel = tableModel;
    }

    public Component getTableCellRendererComponent(JTable jtab, Object v, boolean selected, boolean focus, int r, int c)
    {
        JLabel rendComp = (JLabel) super.getTableCellRendererComponent(jtab, v, selected, focus, r, c);
        
        if (selected) {
            //rendComp.setBackground(Color.BLUE);
        }
        else
        {
            /*if (r % 2 == 0)
                rendComp.setBackground(Color.LIGHT_GRAY);
            else
                rendComp.setBackground(Color.WHITE); */
        }
        if (tableModel.getRowData().getSize() == 5)
        {
            rendComp.setBackground(Color.WHITE);                       
        } 
        if (tableModel.getRowData().getSize() == 3) {
            if (r == 0 || r == 4 || c == 0 || c ==4) {
                rendComp.setBackground(Color.LIGHT_GRAY);
            } else {
                rendComp.setBackground(Color.WHITE);
            }

        }
        return rendComp;
    }
}
